import Vue from 'vue'
import Router from 'vue-router'
import axios from 'axios'
import store from "../store/index.js"
Vue.use(Router)
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err)
}

let router = new Router({
	mode: "history",
	routes: [
		{	// 用户管理
			path:"/account",
			name:"account",
			component:resolve => require(['@/view/account/index'],resolve)
		},
		{	// 求职者管理
			path:"/seeker",
			name:"seeker",
			component:resolve => require(['@/view/seeker/index'],resolve)
		},
		{	// 求职者审核
			path:"/seeker/status",
			name:"seekerStatus",
			component:resolve => require(['@/view/seeker/status'],resolve)
		},
		{	// 企业信息管理
			path:"/company",
			name:"company",
			component:resolve => require(['@/view/company/index'],resolve)
		},
		{	// 企业信息新增
			path:"/company/add",
			name:"companyAdd",
			component:resolve => require(['@/view/company/add'],resolve)
		},
		{	// 企业信息编辑
			path:"/company/edit",
			name:"companyEdit",
			component:resolve => require(['@/view/company/edit'],resolve)
		},
		{	// 企业信息审核
			path:"/company/status",
			name:"companyStatus",
			component:resolve => require(['@/view/company/status'],resolve)
		},
		{	// 平台咨询
			path:"/feedback",
			name:"feedback",
			component:resolve => require(['@/view/feedback/index'],resolve)
		},
		{	// 服务管理
			path:"/server",
			name:"server",
			component:resolve => require(['@/view/server/index'],resolve)
		},
		{	// 维权咨询
			path:"/server/weiquan",
			name:"serverWeiquan",
			component:resolve => require(['@/view/server/weiquan/index'],resolve)
		},
		{	// 创业空间
			path:"/server/chuangye",
			name:"serverChuangye",
			component:resolve => require(['@/view/server/chuangye/index'],resolve)
		},
		{	// 创业空间
			path:"/server/zhandian",
			name:"serverZhandian",
			component:resolve => require(['@/view/server/zhandian/index'],resolve)
		},
		{	// 集市活动
			path:"/server/jishi",
			name:"serverJishi",
			component:resolve => require(['@/view/server/jishi/index'],resolve)
		},
		{	// 招聘活动
			path:"/server/zhaopin",
			name:"serverZhaopin",
			component:resolve => require(['@/view/server/zhaopin/index'],resolve)
		},
		{	// 政务服务
			path:"/server/zhengwu",
			name:"serverZhengwu",
			component:resolve => require(['@/view/server/zhengwu/index'],resolve)
		},
		{	// 技能培训
			path:"/server/jineng",
			name:"serverJineng",
			component:resolve => require(['@/view/server/jineng/index'],resolve)
		},
		{	// 培训机构
			path:"/server/jineng/jigou",
			name:"serverJinengJigou",
			component:resolve => require(['@/view/server/jineng/jigou'],resolve)
		},
		{	// 场地预约
			path:"/server/changdi",
			name:"serverChangdi",
			component:resolve => require(['@/view/server/changdi/index'],resolve)
		},
		{	// 求职
			path:"/job",
			name:"job",
			component:resolve => require(['@/view/job/index'],resolve)
		},
		{	// 求职审核
			path:"/job/status",
			name:"jobStatus",
			component:resolve => require(['@/view/job/status'],resolve)
		},
		{	// 招聘-审核
			path:"/recruit/status",
			name:"recruitStatus",
			component:resolve => require(['@/view/recruit/status'],resolve)
		},
		{	// 招聘列表
			path:"/recruit",
			name:"recruit",
			component:resolve => require(['@/view/recruit/index'],resolve)
		},
		{	// 招聘-新增
			path:"/recruit/add",
			name:"recruitAdd",
			component:resolve => require(['@/view/recruit/add'],resolve)
		},
		{	// 招聘-编辑
			path:"/recruit/update",
			name:"recruitUpdate",
			component:resolve => require(['@/view/recruit/update'],resolve)
		},
		{	// 数据字典
			path:"/dictionary",
			name:"dictionary",
			component:resolve => require(['@/view/dictionary/index'],resolve)
		},
		{	// 数据字典新增数据
			path:"/dictionary/add",
			name:"dictionaryAdd",
			component:resolve => require(['@/view/dictionary/add'],resolve)
		},
		{	// 数据字典编辑数据
			path:"/dictionary/update",
			name:"dictionaryUpdate",
			component:resolve => require(['@/view/dictionary/update'],resolve)
		},
		{
			path: '/configure',
			name: 'configure',
			component: resolve => require(['@/view/configure/configure'], resolve),
			redirect: "/web_configure",
			children: [{
					path: '/web_configure',
					name: 'web_configure',
					component: resolve => require(['@/view/configure/children/webConfigure'], resolve),
				},
				{
					path: '/backstage',
					name: 'backstage',
					component: resolve => require(['@/view/configure/children/backstage'], resolve),
				},
			]
		},
		{ // 操作日志
			path: '/log',
			name: 'log',
			component: resolve => require(['@/view/log'], resolve),
		},
		{ // 位置
			path: '/ad/sort',
			name: 'adSort',
			component: resolve => require(['@/view/ad/adSort'], resolve),
		},
		{ // 广告管理-修改
			path: '/ad/update',
			name: 'adUpdate',
			component: resolve => require(['@/view/ad/adUpdate'], resolve),
		},
		{ // 广告管理-新增
			path: '/ad/add',
			name: 'ad/add',
			component: resolve => require(['@/view/ad/adAdd'], resolve),
		},
		{ // 广告管理
			path: '/ad',
			name: 'ad',
			component: resolve => require(['@/view/ad/ad'], resolve),
		},
		{ // 分类-编辑
			path: '/sort/update',
			name: 'sortUpdate',
			component: resolve => require(['@/view/info/sortUpdate'], resolve),
		},
		{ // 分类-新增
			path: '/sort/add',
			name: 'sortAdd',
			component: resolve => require(['@/view/info/sortAdd'], resolve),
		},
		{ // 分类-修改
			path: '/sort',
			name: 'sort',
			component: resolve => require(['@/view/info/infoSort'], resolve),
		},
		{ // 内容-编辑
			path: '/info/update',
			name: 'infoUpdate',
			component: resolve => require(['@/view/info/infoUpdate'], resolve),
		},
		{ // 内容-新增
			path: '/info/add',
			name: 'infoAdd',
			component: resolve => require(['@/view/info/infoAdd'], resolve),
		},
		{ // 内容-列表
			path: '/info',
			name: 'info',
			component: resolve => require(['@/view/info/info'], resolve),
		},
		{ // 管理员-列表
			path: '/user',
			name: 'user',
			component: resolve => require(['@/view/power/user/user'], resolve),
		},
		{ // 管理员-新增
			path: '/user/add',
			name: 'user_add',
			component: resolve => require(['@/view/power/user/userAdd'], resolve),
		},
		{ // 管理员-修改
			path: '/user/update',
			name: 'user_update',
			component: resolve => require(['@/view/power/user/userEdit'], resolve),
		},
		{ // 角色-列表
			path: '/role',
			name: 'role',
			component: resolve => require(['@/view/power/role/role'], resolve),
		},
		{ // 角色-新增
			path: '/role/add',
			name: 'role_add',
			component: resolve => require(['@/view/power/role/roleAdd'], resolve),
		},
		{ // 保险追踪
			path: '/insurance',
			name: 'insurance',
			component: resolve => require(['@/view/insurance'], resolve),
		},
		{
			path: '/sign',
			name: 'sign',
			component: resolve => require(['@/view/sign'], resolve),
		},

		{
			path: '/',
			name: '',
			component: resolve => require(['@/view/index'], resolve),
		},
		{
			path: '*',
			redirect: "/"
		},
	]
})

export default router

router.beforeEach((to, from, next) => {
	let token = store.state.token;
	if (token != "" || to.path == '/sign') {
		next()
	} else {
		next('/sign')
	}
})
